const { Service } = require('dx-router-admin');
const { DxTest } = require('dx-func-entity');

module.exports = class Test extends Service {
	constructor(ctx) {
		super(ctx);
		this.entity = DxTest;
	}
	init() {
		this.$on('before_insert', async function (data) {
			let row = await this.find();
			console.log(row, data);
		});
		this.$on('after_insert', async function (data) {
			console.log(data);
		});
	}
	user() {
		return this.hasOne('uni-id-users', 'user_id', '_id').bindField({
			user_nickname: 'nickname',
		});
	}
	resource() {
		return this.hasOne('dx-resource', 'source_id', '_id');
	}
};
